package cloud.seri.iot.manager.domain

import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.Field
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.core.mapping.DBRef
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size

import java.io.Serializable
import java.util.Objects
import javax.persistence.Entity

/**
 * The commodity entity.
 * @author A true hipster
 */
@Document(collection = "seri_commodity")
@Entity
class Commodity(

    @Id
    var id: String? = null,

    /**
     * 商品名称
     */
    @get: NotNull
    @Field("name")
    var name: String? = null,

    /**
     * 商品原价
     */
    @Field("original_price")
    var originalPrice: Int? = null,

    /**
     * 现价
     */
    @get: NotNull
    @Field("current_price")
    var currentPrice: Int? = null,

    /**
     * 商品描述
     */
    @Field("description")
    var description: String? = null,

    /**
     * 商品图片
     */
    @Field("pic")
    var pic: String? = null,

    /**
     * 状态
     */
    @Field("status")
    var status: Int? = null

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
) : Serializable {
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is Commodity) return false
        if (other.id == null || id == null) return false

        return Objects.equals(id, other.id)
    }

    override fun hashCode(): Int {
        return 31
    }

    override fun toString(): String {
        return "Commodity{" +
            "id=$id" +
            ", name='$name'" +
            ", originalPrice=$originalPrice" +
            ", currentPrice=$currentPrice" +
            ", description='$description'" +
            ", pic='$pic'" +
            ", status=$status" +
            "}"
    }

    companion object {
        private const val serialVersionUID = 1L
    }
}
